﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_BBS_GetBulletin]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_BBS_GetBulletin];
GO
CREATE PROCEDURE [dbo].[sproc_BBS_GetBulletin]
@type int
AS
/*-----------------------------
功能：得到所有系统公告
参数：
@type    int    :    表示得到的公告类型
            0得到所有版快的板块公告
            -1得到系统公告
            -2得到桌面公告
            其他得到所在板块的公告

--------------------------------*/
    IF(@type=0)
    BEGIN
        SELECT * FROM uds_bbs_forumItem
        WHERE bulletin=1
        ORDER BY send_time 
    END
    ELSE    IF (@type=-1)
    BEGIN
        SELECT * FROM uds_bbs_forumItem 
        WHERE sysbulletin=1
        ORDER BY send_time 
    END
    ELSE    IF (@type=-2)
    BEGIN
        SELECT * FROM uds_bbs_forumItem 
        WHERE sysbulletin=1 AND desktop=1
        ORDER BY send_time 
    END
    ELSE
        SELECT * FROM uds_bbs_forumItem 
        WHERE bulletin=1 AND board_id=@type
        ORDER BY send_time